home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / system / linux_bo / netboot.zoo / rom.asm < prev    next >
Encoding:
Assembly Source File  |  1993-05-06  |  1.7 KB  |  98 lines

  1. include layout.inc
  2.  
  3. _TEXT    SEGMENT BYTE PUBLIC 'CODE'
  4.  
  5.     ASSUME    CS:_TEXT
  6.     ASSUME    DS:_TEXT
  7.  
  8.     PUBLIC    START
  9.     extrn    _romstart:near
  10.  
  11. ;    public    __acrtused    ;This value makes many of the
  12. ; __acrtused = 9876h        ;library routines happy
  13. ; should have no library routines!
  14.  
  15. ifdef UNDER_DOS
  16.     ORG    100h
  17. else
  18.     org 0
  19. endif
  20. START    PROC    NEAR
  21. ifdef REALLY_ROM
  22.     dw    0aa55h        ; rom signature
  23.     db    08000h / 512    ; size
  24. endif
  25. ifdef ROM_CODE
  26.     pop    dx
  27.     pop    ax
  28.     mov    bx, 100h
  29.     mov    cx, 6bf0h
  30.     mov    ss,bx        ; put stack at 100:6bf0 -> 7bf0
  31.     mov    sp,cx
  32.  
  33.     push    ax        ; push far return address
  34.     push    dx
  35.  
  36.     MOV    DX,CS        ; 
  37.     mov    ds,dx        ; going to move ds:si to es:di
  38.  
  39.     cld
  40.     mov    es,bx
  41.     xor    di,di        ; clear dest
  42.     mov    si,OFFSET CGROUP:_start_of_data 
  43.                 ; move _DATA segment
  44.     mov    cx, offset dgroup:_end_of_data
  45.     rep movsb
  46.                 ; now clear _BSS segment
  47.     mov    cx, offset dgroup:_end_of_bss
  48.     sub    cx, offset dgroup:_end_of_data
  49.     mov    al,0
  50.     rep stosb
  51.  
  52.     mov    ax,100h
  53.     mov    es,ax
  54.     mov    ds,ax    
  55.     STI            ;Enable interrupts and the jump
  56.     call    _romstart    ;to the start of the C code
  57.  
  58. else
  59.     MOV    DX,CS        ; 
  60.     mov    ax,9800h    ; nice high place
  61.     mov    es,ax
  62.     cld
  63.     xor    di,di        ; clear dest
  64.     xor    si,si
  65.     mov    cx, offset dgroup:_end_of_data
  66.     rep movsb
  67.                 ; now clear _BSS segment
  68.     mov    cx, offset dgroup:_end_of_bss
  69.     sub    cx, offset dgroup:_end_of_data
  70.     mov    al,0
  71.     rep stosb
  72.  
  73.     cli
  74.     mov    ax,9800h    ; nice high place
  75.     mov    ds,ax
  76.     mov    es,ax
  77.     mov    ss,ax    
  78.     mov    sp, 07ffeh    ; stack
  79. ; I'm tired and I can't be bothered fighting this assembler
  80.     db    0eah        ; far jump
  81.     dw    offset dgroup: here_i_am
  82.     dw    09800h
  83. here_i_am:
  84.     STI            ;Enable interrupts and the jump
  85.     call    _romstart    ;to the start of the C code
  86. endif
  87.  
  88. ifdef UNDER_DOS
  89.     int    19h
  90. endif
  91.     retf
  92. START    ENDP
  93.  
  94. _TEXT    ENDS
  95.  
  96.     END START
  97.  
  98.